import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { DiningTableApi } from '#/api/spa/dining/table';

import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'groupId',
      label: '集团ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'restaurantId',
      label: '餐厅ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐厅ID',
      },
    },
    {
      fieldName: 'tableCode',
      label: '餐桌编号',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐桌编号',
      },
    },
    {
      fieldName: 'tableTypeId',
      label: '餐桌类型ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐桌类型ID',
      },
    },
    {
      fieldName: 'tableName',
      label: '餐桌名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐桌名称',
      },
    },
    {
      fieldName: 'capacity',
      label: '容纳人数',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入容纳人数',
      },
    },
    {
      fieldName: 'status',
      label: '餐桌状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'floorNumber',
      label: '楼层号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入楼层号',
      },
    },
    {
      fieldName: 'areaName',
      label: '区域名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入区域名称',
      },
    },
    {
      fieldName: 'tablePosition',
      label: '餐桌位置描述',
      component: 'Input',
      componentProps: {
        placeholder: '请输入餐桌位置描述',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'groupId',
      label: '集团ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入集团ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'restaurantId',
      label: '餐厅ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐厅ID',
      },
    },
    {
      fieldName: 'tableCode',
      label: '餐桌编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐桌编号',
      },
    },
    {
      fieldName: 'tableTypeId',
      label: '餐桌类型ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐桌类型ID',
      },
    },
    {
      fieldName: 'tableName',
      label: '餐桌名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐桌名称',
      },
    },
    {
      fieldName: 'capacity',
      label: '容纳人数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入容纳人数',
      },
    },
    {
      fieldName: 'status',
      label: '餐桌状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择餐桌状态',
      },
    },
    {
      fieldName: 'floorNumber',
      label: '楼层号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入楼层号',
      },
    },
    {
      fieldName: 'areaName',
      label: '区域名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入区域名称',
      },
    },
    {
      fieldName: 'tablePosition',
      label: '餐桌位置描述',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入餐桌位置描述',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<DiningTableApi.DiningTable>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,
    },
    {
      field: 'groupId',
      title: '集团ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'restaurantId',
      title: '餐厅ID',
      minWidth: 120,
    },
    {
      field: 'tableCode',
      title: '餐桌编号',
      minWidth: 120,
    },
    {
      field: 'tableTypeId',
      title: '餐桌类型ID',
      minWidth: 120,
    },
    {
      field: 'tableName',
      title: '餐桌名称',
      minWidth: 120,
    },
    {
      field: 'capacity',
      title: '容纳人数',
      minWidth: 120,
    },
    {
      field: 'status',
      title: '餐桌状态',
      minWidth: 120,
    },
    {
      field: 'floorNumber',
      title: '楼层号',
      minWidth: 120,
    },
    {
      field: 'areaName',
      title: '区域名称',
      minWidth: 120,
    },
    {
      field: 'tablePosition',
      title: '餐桌位置描述',
      minWidth: 120,
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
